package testUnit.proUnitTest;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.sql.Timestamp;

import org.junit.jupiter.api.Test;

import com.situ.staff.employee.model.EmployeeModel;
import com.situ.staff.project.dao.ProjectDao;
import com.situ.staff.project.model.ProjectModel;
//import com.situ.staff.util.JDBCUtil;

public class proTestUnit {
	ProjectDao dao = new ProjectDao();

	@Test
	public void testInsert() {
		Date date = new Date();
		Timestamp timestamp = new Timestamp(date.getTime());
		ProjectModel model = new ProjectModel("001", "GIS", timestamp);
		try {
			dao.insert(model);
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.out.println("插入成功");
	}

	@Test
	public void testdeleteByCode() {
		ProjectModel model = new ProjectModel("001", "GIS", null);
		try {
			dao.deleteByCode(model);
		} catch (Exception e) {
			// TODO: handle exception
		}
		System.out.println("删除完成");
	}

	@Test
	public void testdelete() {
		ProjectModel model = new ProjectModel(null, "CRM", null);
		try {
			dao.delete(model);
		} catch (Exception e) {
			// TODO: handle exception
		}
		System.out.println("删除完成");
	}

	@Test
	public void testupdateAll() {
		Date date = new Date();
		Timestamp timestamp = new Timestamp(date.getTime());
		ProjectModel model = new ProjectModel("002", "CRM", timestamp);
		try {
			dao.updateAll(model);
		} catch (Exception e) {
			// TODO: handle exception
		}
		System.out.println("更新完成");
	}

	@Test
	public void testupdateActive() {
//		Date date = new Date();
//		Timestamp timestamp = new Timestamp(date.getTime());
		ProjectModel model = new ProjectModel("002", "GIS", null);
		try {
			dao.updateActive(model);
		} catch (Exception e) {
			// TODO: handle exception
		}
		System.out.println("更新完成");
	}

	@Test
	public void testselectList() {
		ProjectModel model = new ProjectModel("002", null, null);
		List<ProjectModel> list = new ArrayList<ProjectModel>();
		try {
			list = dao.selectList(model);
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.out.println(list.size());
	}
	
	@Test
	public void testselectModel() {
		ProjectModel model = new ProjectModel("004", null, null);
//		List<ProjectModel> list = new ArrayList<ProjectModel>();
		ProjectModel p1 = new ProjectModel();
		try {
			p1 = dao.selectModel(model);
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.out.println(p1.toString());
	}

}
